<?php
include "dbconnect.php";
$result="";
$option=$_POST["option"];
$con=mysql_connect($dbHost,$dbUserAndName,$dbPass);
mysql_select_db($_DB_NAME,$con);
if($option==1)
{
	$search=$_POST["courseid"];
	if(!empty($search))
		$searchList =	mysql_query("select courseid from courses where courseid like '%".$search."%'");
}
else
{
	$search=$_POST["instructor"];
	if(!empty($search))
		$searchList =	mysql_query("select P_ShortName from professor where P_ShortName like '%".$search."%'");
}
while($row = mysql_fetch_array($searchList))
{
	if(empty($result)==true)
	{
  		$result= $row[0];
	}
	else
	{
		$result= $result.",".$row[0];
	}
}
mysql_close($con);
echo $result;
?>